<?xml version="1.0" encoding='UTF-8'?>
<template
  __format__="1"
  name="POSIX/gcc multithreaded standalone"
  prefix="art_"
  errlogmode="tracefile.err"
  trap_on_io_err="true"
  remote_mode="false"
  force_flush="true"
  fork_enabled="false"
  multithreaded="true"
  art_start_selfinit="true"
  threading="posix"
  compiler_type="gcc"
  trace_target="tracefile.out">

  <!-- domain names have to be spaces-free -->

  <domain
    name="heap-memory"
    float_handle="true"
    handle="void*"
    includesGlobal="true"
    >
    <!-- bad_handle -->
    <expr
      oper="=="
      type="void*"
      value="NULL"
    />
    <includes>stdlib.h</includes>
    <tor
       __type__="allocator"
       name="malloc"
       float_arg_n1="1"
       float_arg_n2="0"
       is_handle_arg_out="true"
       handle_arg_out="0"
       cpp_alias=""
       >
      <validateDom_before></validateDom_before>
      <args
        type="void*"
        name=""
      />
      <args
        type="size_t"
        name="size"
      />
      <!-- badRetCode -->
      <expr
        oper="=="
        type="void*"
        value="NULL"
      />
    </tor>

    <tor
       __type__="allocator"
      name="calloc"
      float_arg_n1="1"
      float_arg_n2="2"
      is_handle_arg_out="true"
      handle_arg_out="0"
      cpp_alias=""
      >
      <validateDom_before></validateDom_before>
      <args
        type="void*"
        name=""
        />
      <args
        type="size_t"
        name="nmemb"
        />
      <args
        type="size_t"
        name="size"
        />

      <!-- badRetCode -->
      <expr
        oper="=="
        type="void*"
        value="NULL"
      />
    </tor>

    <!-- FIXME
    т.к. is_handle_arg_out="false", то handle_arg_out может быть пустым или
    нужна какая-то фиктивная цифра для разборщика? -->
    <tor
      __type__="deallocator"
      name="free"
      float_arg_n1="0"
      float_arg_n2="0"
      is_handle_arg_out="false"
      handle_arg_out=""
      cpp_alias=""
      >
      <validateDom_before>-</validateDom_before>
      <validateDom_before>heap-memory</validateDom_before>
      <args
        type="void"
        name=""
        />
      <args
        type="void *"
        name="ptr"
        />

      <!-- badRetCode -->
      <expr
        oper=""
        type="void"
        value=""
      />

    </tor>

    <!-- torspec:reallocator -->
    <tor
      __type__="reallocator"
      name="realloc"
      float_arg_n1="2"
      float_arg_n2="0"
      is_handle_arg_out="true"
      handle_arg_out="0"
      cpp_alias=""
      >
      <validateDom_before>-</validateDom_before>
      <validateDom_before>heap-memory</validateDom_before>
      <args
        type="void*"
        name=""
        />
      <args
        type="void*"
        name="ptr"
        />
      <args
        type="size_t"
        name="size"
        />
      <!-- badRetCode -->
      <expr
        oper="=="
        type="void*"
        value="NULL"
      />
    </tor>
  </domain>

  <!--
  <specialTors>
  </specialTors>
  -->

  <domain
    name="stream-io"
    float_handle="false"
    handle="FILE*"
    includesGlobal="true"
    >

    <!-- bad_handle -->
    <expr
      oper="=="
      type="FILE*"
      value="NULL"
    />
    <includes>stdio.h</includes>
    <tor
      __type__="allocator"
      name="fopen"
      float_arg_n1="0"
      float_arg_n2="0"
      is_handle_arg_out="true"
      handle_arg_out="0"
      cpp_alias=""
    >
    <validateDom_before></validateDom_before>
    <args
      type="FILE*"
      name=""
    />
    <args
      type="const char*"
      name="path"
    />
    <args
      type="const char*"
      name="mode"
    />

    <!-- badRetCode -->
    <expr
      oper="=="
      type="FILE*"
      value="NULL"
    />
    </tor>

    <tor
      __type__="operator"
      name="fwrite"
      float_arg_n1="2"
      float_arg_n2="3"
      is_handle_arg_out="false"
      handle_arg_out="0"
      cpp_alias=""
    >
    <validateDom_before>-</validateDom_before>
    <validateDom_before>heap-memory</validateDom_before>
    <validateDom_before>-</validateDom_before>
    <validateDom_before>-</validateDom_before>
    <validateDom_before>stream-io</validateDom_before>
    <args
      type="size_t"
      name=""
    />
    <args
      type="const void*"
      name="ptr"
    />
    <args
      type="size_t"
      name="size"
    />
    <args
      type="size_t"
      name="nmemb"
    />
    <args
      type="FILE*"
      name="stream"
    />

    <!-- badRetCode -->
    <!-- тут RetCode не так прост, например: If an error, or the end-of-file
    is reached, the return value is a short item count (or zero).
    fread() does not distinguish between end-of-file and error, and callers
    must use feof(3) and ferror(3) to determine which occurred. -->
    <expr
      oper=""
      type=""
      value=""
    />
    </tor>

    <tor
      __type__="deallocator"
      name="fclose"
      float_arg_n1="0"
      float_arg_n2="0"
      is_handle_arg_out="false"
      handle_arg_out=""
      cpp_alias=""
      >
      <validateDom_before>-</validateDom_before>
      <validateDom_before>stream-io</validateDom_before>
      <args
        type="int"
        name=""
        />
      <args
        type="FILE*"
        name="fp"
        />
      <!-- badRetCode -->
      <expr
        oper="!="
        type="int"
        value="0"
        />
    </tor>
  </domain>
</template>
